package net.xxcxcxcx.xc_enhancedmob.event;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.util.ActionResult;

/**
 * 击杀事件
 */
public interface onDeathCallback {
    Event<onDeathCallback> EVENT = EventFactory.createArrayBacked(onDeathCallback.class,
            (listeners) -> (attacker, target, source, ismob, remote) -> {
                for (onDeathCallback listener : listeners) {
                    ActionResult result = listener.onDeath(attacker, target, source, ismob, remote);
                    if (result != ActionResult.PASS) {
                        return result;
                    }
                }
                return ActionResult.PASS;
            }
    );

    ActionResult onDeath(LivingEntity attacker, LivingEntity target, DamageSource source, boolean ismob, boolean remote);
}
